package com.winway.boot.controller;

import com.winway.common.model.Result;
import com.winway.framework.sap.client.SAPWebServiceClient;
import com.winway.framework.sap.client.ZBF_MASTERStub;
import com.winway.framework.unit.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * 首页控制器
 */
@Tag(name = "首页接口", description = "用于测试系统是否正常运行")
@RestController
@RequestMapping("/test")
public class AdminIndexController {


    /**
     * 首页测试接口
     */
    @Operation(summary = "首页测试接口", description = "用于测试系统是否正常运行")
    @GetMapping("/index")
    public Result<String> index() throws Exception {
        String[] sapArray = {"M124", "1000", "", "7000181"};
        List<String> list2 = Arrays.asList(sapArray);
        //调用SAP接口,同步成品物料
        SAPWebServiceClient client = new SAPWebServiceClient();
        ZBF_MASTERStub.ZbfMaster[] zbfMasters1 = client.SAPMasterWebServiceInit(list2);
        if (zbfMasters1 != null) {
            for (ZBF_MASTERStub.ZbfMaster zbfMaster : zbfMasters1) {

            }
        }
        System.out.println(SecurityUtils.getUsername());
        return Result.success("SRM管理端启动成功!");
    }

}
